Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 251af4b1003209fd71e9f25ef5ecff34c3b114c0


Parents : 261a07a
Author : Ivan <ivan@quad4.io>
Signature : Invalid signer <e46112d44649266d71fe2193e00a4710>, author is <ivan@quad4.io>
Date : 2026-06-29T06:26:19-05:00

feat(build): add bleak wheel handling to build.gradle and update build script for Android

Changes

2 files changed, 41 insertions(+), 2 deletions(-)


Diff

diff --git a/android/app/build.gradle b/android/app/build.gradle
index 2e8abe24..f682a60d 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -10,6 +10,7 @@ def chaquopyBuildPython = System.getenv("CHAQUOPY_BUILD_PYTHON")
def pythonTempDir = new File(buildDir, "python-tmp")
def vendorWheelDir = new File(rootProject.projectDir, "vendor")
def lxstPatchedWheel = new File(rootProject.projectDir, "vendor/lxst-0.4.7-py3-none-any.whl")
+def bleakPatchedWheel = new File(rootProject.projectDir, "vendor/bleak-3.0.2-py3-none-any.whl")
def allAndroidAbis = ["arm64-v8a", "x86_64", "armeabi-v7a"]
def selectedAndroidAbis = (
project.findProperty("meshchatxAbis")
@@ -236,6 +237,10 @@ chaquopy {
throw new org.gradle.api.GradleException("Missing patched LXST wheel at ${lxstPatchedWheel}")
}
install lxstPatchedWheel.absolutePath
+ if (!bleakPatchedWheel.exists()) {
+ throw new org.gradle.api.GradleException("Missing patched bleak wheel at ${bleakPatchedWheel}")
+ }
+ install bleakPatchedWheel.absolutePath
install "psutil>=7.2.2"
install "websockets>=16.0"
install "bcrypt==3.1.7"

diff --git a/scripts/build-android-wheels-local.sh b/scripts/build-android-wheels-local.sh
index fd809139..db695d99 100755
--- a/scripts/build-android-wheels-local.sh
+++ b/scripts/build-android-wheels-local.sh
@@ -747,13 +747,47 @@ fi
if [[ -z "${ONLY_RECIPES}" ]]; then
echo "Fetching bleak ${BLEAK_VERSION} pure-python wheel"
+ BLEAK_TMP_DIR="$(mktemp -d)"
+
"${VENV_DIR}/bin/pip" download \
--only-binary=:all: \
--no-deps \
"bleak==${BLEAK_VERSION}" \
- --dest "${OUT_DIR}" \
+ --dest "${BLEAK_TMP_DIR}" \
--index-url https://pypi.org/simple
- if ! ls "${OUT_DIR}"/bleak-"${BLEAK_VERSION}"-py3-none-any.whl >/dev/null 2>&1; then
+
+ BLEAK_WHEEL="$(ls "${BLEAK_TMP_DIR}"/bleak-"${BLEAK_VERSION}"-py3-none-any.whl)"
+ PATCHED_BLEAK_WHEEL="${OUT_DIR}/bleak-${BLEAK_VERSION}-py3-none-any.whl"
+
+ # Android uses bleak's p4android backend (pyjnius). The platform-specific
+ # backend requirements (dbus-fast on Linux, pyobjc on macOS, winrt on
+ # Windows) are useless on Android and dbus-fast has no Android wheel, so
+ # strip them from the wheel metadata before bundling.
+ "${VENV_DIR}/bin/python" - <<PY
+import zipfile
+from pathlib import Path
+
+src = Path("${BLEAK_WHEEL}")
+dst = Path("${PATCHED_BLEAK_WHEEL}")
+
+def keep(line):
+ if not line.startswith("Requires-Dist:"):
+ return True
+ return "sys_platform ==" not in line
+
+with zipfile.ZipFile(src, "r") as zin, zipfile.ZipFile(dst, "w", compression=zipfile.ZIP_DEFLATED) as zout:
+ for item in zin.infolist():
+ data = zin.read(item.filename)
+ if item.filename.endswith(".dist-info/METADATA"):
+ text = data.decode("utf-8")
+ text = "\n".join(line for line in text.splitlines() if keep(line)) + "\n"
+ data = text.encode("utf-8")
+ zout.writestr(item, data)
+PY
+
+ rm -rf "${BLEAK_TMP_DIR}"
+
+ if ! ls "${PATCHED_BLEAK_WHEEL}" >/dev/null 2>&1; then
echo "Expected bleak-${BLEAK_VERSION}-py3-none-any.whl in ${OUT_DIR}" >&2
exit 1
fi


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────